"""Definition of the Atractivo content type
"""

from zope.interface import implements, directlyProvides

from Products.Archetypes import atapi
from Products.ATContentTypes.content import base
from Products.ATContentTypes.content import schemata

from newguegue.newmunicipios import newmunicipiosMessageFactory as _
from newguegue.newmunicipios.interfaces import IAtractivo
from newguegue.newmunicipios.config import PROJECTNAME

AtractivoSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((

    # -*- Your Archetypes field definitions here ... -*-
   atapi.StringField('title',
                searchable=1,
                isMetadata=0,
                accessor='Title',
                required=1,
                widget=atapi.StringWidget(label='Título',
                                      maxlength=150,
                                      size=30,
                                      label_msgid="label_entry_title",
                                      description_msgid="help_entry_title",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Nombre del atractivo turistico')),
    atapi.StringField('description',
                searchable=1,
                isMetadata=0,
                required=1,
                accessor='Description',
                widget=atapi.TextAreaWidget(label='Breve descripción',
                                      label_msgid="label_entry_description",
                                      description_msgid="help_entry_description",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Entre una breve descripción.')),
    atapi.TextField('ubicacion',
                searchable=0,
                isMetadata=0,
                required=1,
           	default_content_type='text/html',
              	default_output_type='text/html',
              	allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
              	widget=atapi.RichWidget(label='Ubicación',
                                label_msgid="label_entry_ubicacion",
                                description_msgid="help_entry_ubicacion",
                                i18n_domain="newguegue.newmunicipios",
                                description="Ubicación")),
    atapi.TextField('servicios',
                searchable=1,
                isMetadata=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Servicios',
                                      label_msgid="label_entry_servicios",
                                      description_msgid="help_entry_servicios",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Servicios')),
    atapi.StringField('costo',
                searchable=1,
                isMetadata=0,
                required=1,
                widget=atapi.StringWidget(label='Costos',
                                      maxlength=400,
                                      size=60,
                                      label_msgid="label_entry_costo",
                                      description_msgid="help_entry_costo",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Costo')),
    atapi.StringField('contacto',
                searchable=0,
                isMetadata=0,
                required=1,
                widget=atapi.StringWidget(label='Nombre del contacto',
                                      maxlength=80,
                                      size=60,
                                      label_msgid="label_entry_contacto",
                                      description_msgid="help_entry_contacto",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Nombre del contacto')),
    atapi.StringField('telefono',
                searchable=0,
                isMetadata=0,
                required=1,
                widget=atapi.StringWidget(label='Teléfono del contacto',
                                      label_msgid="label_entry_telefono",
                                      description_msgid="help_entry_telefono",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Teléfono del contacto')),
    atapi.StringField('email',
                searchable=0,
                isMetadata=0,
                widget=atapi.StringWidget(label='Email del contacto',
                                      label_msgid="label_entry_email",
                                      description_msgid="help_entry_email",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Email del contacto')),
    atapi.StringField('web',
                searchable=0,
                isMetadata=0,
                widget=atapi.StringWidget(label='Sitio web',
                                      label_msgid="label_entry_web",
                                      description_msgid="help_entry_web",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Sitio web')),
    atapi.ImageField('image',
              searchable=0,
              required=1,
              accessor='Image',
              widget=atapi.ImageWidget(label='Imagen',
                                label_msgid="label_entry_image",
                                description_msgid="help_entry_image",
                                i18n_domain="newguegue.newmunicipios",
                                threshold=204800,
                                description='Puede adjuntar una imagen relacionada.')),
    atapi.TextField('body',
              searchable=1,
              required=1,
              primary=1,
              default_content_type='text/html',
              default_output_type='text/html',
              allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
              widget=atapi.RichWidget(label='Descripcion',
                                label_msgid="label_entry_body",
                                description_msgid="help_entry_body",
                                i18n_domain="newguegue.newmunicipios",
                                description="Descripción completa")),
    atapi.TextField('video',
                searchable=1,
                isMetadata=0,
                default_content_type='text/html',
                default_output_type='text/html',
                allowable_content_types=('text/plain','text/structured', 'text/html', 'text/restructured'),
                widget=atapi.RichWidget(label='Video',
                                      label_msgid="label_entry_video",
                                      description_msgid="help_entry_video",
                                      i18n_domain="newguegue.newmunicipios",
                                      description='Video.')),
))

# Set storage on fields copied from ATContentTypeSchema, making sure
# they work well with the python bridge properties.

#AtractivoSchema['title'].storage = atapi.AnnotationStorage()
#AtractivoSchema['description'].storage = atapi.AnnotationStorage()

schemata.finalizeATCTSchema(AtractivoSchema, moveDiscussion=False)

class Atractivo(base.ATCTContent):
    """Atractivos"""
    implements(IAtractivo)

    portal_type = "Atractivo"
    schema = AtractivoSchema

    def tag(self, **kwargs):
        """Generate image tag using the api of the ImageField
        """
        return self.getField('image').tag(self, **kwargs)

 #   title = atapi.ATFieldProperty('title')
 #   description = atapi.ATFieldProperty('description')

atapi.registerType(Atractivo, PROJECTNAME)
